import instance from '../utils/http'
/**
 * 有关购物车和支付的相关api
 */


 /**
  * 加入购物车
  * @param {buycar}} buycar 
  */
 export const addBuyCar=(buycar)=>{
  return instance.post("/buycar/addBuyCar",buycar);
 }
/**
 * 根据id查询购物车信息及结算
 * @param {userid} 用户id 
 */
 export const selectBuyCar=(userid)=>{
   return instance.get(`/buycar/selectBuyCar/?userid=${userid}`)
 }
/**
 * 修改购物车数量
 * @param {buycar} buycar 
 */
 export const updateCount=(buycar)=>{
   return instance.post("/buycar/updateCount",buycar);
 }
/**
 * 删除购物车
 * @param {*} buyid 
 */
 export const deleteBuy=(buyid)=>{
   return instance.post("/buycar/deleteBuyapi",buyid);
 }
/**
 * 删除所有购物车
 * @param {*} userid 
 */
 export const deletAllBuyApi=(userid)=>{
   return instance.post("/buycar/deletAllBuyApi",userid);
 }
/**
 * 立即购买返回对应接口
 * @param {*} buycar 
 */
 export const nowBuy=(buycar)=>{
   return instance.post("/buycar/nowBuy",buycar);
 }
/**
 * 订单生成方法
 * 添加支付信息和订单信息以及减少优惠券
 */
 export const lastPayapi=(orderpayinfo,userdiscount)=>{
   return  instance.post("/orderpayinfo/savepayinfo",{"orderpayinfo":orderpayinfo,"userdiscount":userdiscount});
 }

 export const loadcakeidapi=(paycakeid)=>{
   return instance.post("/paycake/loadcakeidapi",paycakeid)
 }
/**
 * 查询购物车总数
 * @param {\} cakeid 
 */
 export const selectBuycarhascount=(cakeid)=>{
   return instance.post("/buycar/selectBuycarhascount",cakeid)
 }

 /**
  * 根据蛋糕id修改购物车数量
  * @param {*} buycar 
  */
 export const updateCountCakeid=(buycar)=>{
   return instance.post("/buycar/updateCountCakeid",buycar)
 }


 /**
  * 判断蛋糕是否下架
  * @param {*} cakeid 
  */
 export const ifcakeStatusapi=(cakeid)=>{
   return instance.post("/cake/ifcakeStatusapi",cakeid);
 }